﻿#region Header
// ------------------------ Licence / Copyright ------------------------
// 
// ScrumTable for Scrum Meeting Support
// Copyright © HSR - Hochschule für Technik Rapperswil
// All Rights Reserved
// 
// Author:
//  Michael Gfeller Silvan Gehrig Patrick Boos
// 
// ---------------------------------------------------------------------
#endregion

namespace ScrumTable.Common.Logging
{
    #region Usings

    using System.IO;
    using System.Threading;
    using log4net.Config;

    #endregion

    /// <summary>
    /// Provides static methods which are used to initialize the logging
    /// framework.
    /// </summary>
    public static class LoggerConfig
    {
        #region Declarations
        //--------------------------------------------------------------------
        // Declarations
        //--------------------------------------------------------------------

        #endregion

        #region Properties
        //--------------------------------------------------------------------
        // Properties
        //--------------------------------------------------------------------

        #endregion

        #region Methods
        //--------------------------------------------------------------------
        // Methods
        //--------------------------------------------------------------------

        /// <summary>
        /// Initializes the Logging framework using the given xml
        /// configuration file.
        /// </summary>
        /// <param name="xmlConfigFile">Relative or absolute path to the configuration xml file.</param>
        public static void RegisterConfigFile(string xmlConfigFile)
        {
            if (string.IsNullOrEmpty(Thread.CurrentThread.Name))
            {
                Thread.CurrentThread.Name = "StartupThread"; // mark current thread as start up thread
            }

            using (FileStream fileToRead = File.Open(xmlConfigFile, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                XmlConfigurator.Configure(fileToRead);
            }
        }

        #endregion
    }
}
